<?php
namespace app\admin\model;
use think\Model;

class Brand extends Model{
    public function searchKeywordsAttr($q,$v)
    {
        $q->where('brand_name','like',"%{$v}%");
    }
    public function searchIfShowAttr($q,$v)
    {
        $q->where('if_show','in',$v);
    }
    public function searchRecommendedAttr($q,$v)
    {
        $q->where('recommended','=',$v);
    }
    public static function getBrand($where)
    {
        $list=self::withSearch(array_keys($where),$where)
            ->order('sort_order','asc')
            ->paginate([
                'list_rows'=>5,
                'query'=>$where
            ]);
        return  $list;
    }
}